<!-- 普通游戏组件 -->
<template>
  <div class="card" @mouseenter="changePics()" @click="toDetail" :class="{'hover-color': num == $store.state.shop.hoverGame }">
    <img :src="`${game.photo}`" alt="">
    <!-- 信息展示 -->
    <div class="info">
        <div class="i-left">
            <span :class="{'hover-color': num == $store.state.shop.hoverGame }" class="tit">{{ game.gname }}</span>
            <span class="tags">{{ game.moretype }}</span>
        </div>
        <div class="i-right" :class="{'hover-color': num == $store.state.shop.hoverGame }">
            <span class="price" v-if="game.price!=0">￥{{ game.price }}</span>
            <span class="price" v-else>免费</span>
        </div>
    </div>
    <div class="interval" :class="{'hover-color': num == $store.state.shop.hoverGame }">

    </div> 
  </div>
</template>

<script>
export default {
    props:{
        num: 0, 
        game:{
            type: Object,
            default: {},
        },
    }, 
    data(){ 
        return{

        }
    },
    methods:{
        changePics(){
            this.$store.commit('changeHover',this.num);
        },
        // 点击游戏进入游戏详情页
        toDetail(){
            this.$store.commit('saveCurGame',this.num);
            this.$router.push(`/home/detail?id=1`);
        }
    }

}
</script> 

<style scoped lang="less">
.hover-color{
    color: #333!important;
    background-color: #A6CAE0!important;
    
}
.card{
    height: 70px;
    width: 100%;
    margin: 3px 0px;
    margin-right: 4px;
    display: flex;
    background-color: #1C2D3D;
    cursor: pointer;
    img{
        height: 70px;
        width: 180px;
        object-fit: cover;
        object-position: center;
    }
    .info{
        transition: all 0.2s linear;
        width: calc(100% - 188px);
        box-sizing: border-box;
        padding: 10px 12px;
        display: flex;
        justify-content: space-between;
        .i-left{
            width: 80%;
            text-align: left;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            .tit{
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                color: #C7D5E0;
            }
            .tags{
                font-size: 13px;
                color: #384959;
            }
        }
        .i-right{
            text-align: right;
            width: 20%;
            height: 50px;
            line-height: 50px;
            color: #C7D5E0;
            font-size: 15px;
        }
    }
    .interval{
        width: 8px;
        height: 100%;
        background-color: #284258;
        cursor: default;
    }
}
</style>